<style>

#cost_val_red
{
	font:bold 18px "Arial";	
	color:#FF0000;
}

#cost_val_green
{
	font:bold 18px "Arial";	
	color:#00CC00;
}

#cost_val_black
{
	font:bold 18px "Arial";	
	color:#000000;
}

</style>

 

<html>
 <head>
    <title>[var.TITLE]</title>
    <link href="[var.ROOT_CSS_DIR]/main.css" rel="STYLESHEET" type="text/css" charset="iso-8859-1" hreflang="en-us">
    <link href="[var.ROOT_CSS_DIR]/facet/style.css" rel="STYLESHEET" type="text/css" charset="iso-8859-1" hreflang="en-us">
    <script type="text/javascript" src="[var.ROOT_DIR]js/common.js"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/doiMenuDOM.js"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/functions.js"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jsmenu.php"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jsmenu.cfg"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jsformgrid.php?session=[var.SessionVar]"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jsmasks.js"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jsverify.php?session=[var.SessionVar]"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jsinit.php?session=[var.SessionVar]"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jquery.min.js"></script>
    <script type="text/javascript" src="[var.ROOT_DIR]js/jsformgridnew.js"></script>
 </head>
 <body bgcolor="FFFFFF" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
    <table border="0" cellspacing="0" cellpadding="0" width="100%" align="[var.POSITION]">
        <tr>
            <td>[tbs_include.onshow;file=[var.HTMLHeader];getob;]</td>
        </tr>
        <tr>
            <td>
            <table border="0" cellspacing="0" cellpadding="0" width="100%">
                <tr>
                    <td class="mainmenu2"><img src="images/spacer.gif" height="1" width="1"></td>
                </tr>
                <tr>
                    <td background="[var.ROOT_IMG_DIR]/back-menu.gif">
                    <table border="0" cellspacing="0" cellpadding="0" width="100%">
                        <tr>
                            <td>
                                <script language="JavaScript" type="text/JavaScript">menu.Build();</script>
                          </td>
                          <td class="head-login">Login as [var.USERPROFILE_NAME]</td>
                        </tr>
                      </table>
                    </td>
                </tr>

                <tr>
                    <td class="mainmenu2"><img src="images/spacer.gif" height="1" width="1"></td>
                </tr>
            </table>
            </td>
        </tr>
        <tr height="100%">
            <td>
            <table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%">
                <tr valign="top">
                    <td width="100%">
                        <table border="0" cellspacing="0" cellpadding="0" width="100%">
                            <tr>
                                <td class="head-path"></td>
                                <td class="corner-date">[var.CORNER_DATE]</td>
                            </tr>
                        </table>
                        <table border="0" cellspacing="0" cellpadding="5" width="100%">
                            <tr>
                                <td class="FacetHeaderContent" >.:[var.SubHeaderTitle]:.</td>
                            </tr>
                        </table>


                    <form method="post" action="[var.FormAction]" name="[var.HTMLFormName]" >
                        <table border="0" cellspacing="0" cellpadding="5" width="100%">
                            <tr>
                                <td class="contentTitleOperational">
                                Menu
                                </td>
                            </tr>
                            <tr>
                                <td class="contentOperational">
                                <table cellspacing="2" cellpadding="0">
                                 <tr>
                                   <td>
                                    <input type="button" name="Action" value="<<Back" class="button" onClick="self.location.replace('[sys.script_name]')">
                                   </td>
                                    <td>
                                     <input type="button" name="Action" value="Done" class="button" onClick="self.location.replace('[var.SERVER_URL]')">
                                   </td>
                                   <td>
                                    <!--input name="FormAction" type="submit" value="Save" class="button" onClick="return CheckAll();"-->
                                   </td>

                                 </tr>
                                </table>
                                </td>
                            </tr>
                            <tr>
                                <td class="contentOperational">

                         <!--TABLE MASTER-->
                         <table width="35%" border="0">
                             <tr>
                                 <td width="35%" valign="top">
                                 
                                      
                                       
									   <table border="0" cellspacing="0" cellpadding="0" width="100%">
                                           <tr>
                                                
                                                <!-- FORM BLOCK -->
                                                <td>

													<!-- FORM SECTION -->
													<table border="0" cellspacing="0" cellpadding="0">

													<!--form method="post" action="[var.FormAction]" name="[var.HTMLFormName]" -->
														  <tr>
															<td class="fieldCaption" align="right">Job Order Code</td>
															<td class="fieldCaption">:</td>
															<td class="fieldCaption"><b>
																[tbs_check;htmlconv=no;if [var.FormMode]=Edit;then '[headblv.jo_code;noerr]<input type="hidden" id="jo_id" name="jo_id" value="[headblv.jo_id;noerr]">';else'AUTO GENERATE BY SYSTEM<input type="hidden" id="jo_id" name="jo_id" value="AUTO NUMBERED BY SYSTEM">']</b>
															</td>
															
														  </tr>
														  <tr>
															<td class="fieldCaption" align="right">Document Reference</td>
															<td class="fieldCaption">:</td>
															<td class="fieldCaption">
																[headblv.doc_ref;noerr]
															</td>

														  </tr>
														  <tr>
															<td class="fieldCaption" align="right">Project Name</td>
															<td class="fieldCaption">:</td>
															<td class="fieldCaption">
																[headblv.project_name]

																<input type="hidden" name="project_id" value="[headblv.project_id;noerr]" class="input" maxlength="50" size="10">

															</td>
														  </tr>
														  <tr>
															<td class="fieldCaption" align="right">Customer</td>
															<td class="fieldCaption">:</td>
															<td class="fieldCaption">
																[headblv.CUNAME;noerr]

															</td>
														  </tr>
														  <tr>
															<td class="fieldCaption" align="right">Job Order Staff</td>
															<td class="fieldCaption">:</td>
															<td class="fieldCaption">
																[headblv.staff_marketing;noerr]

															</td>
														  </tr>
														  <tr>
															<td class="fieldCaption" align="right">Job Order Date</td>
															<td class="fieldCaption">:</td>
															<td class="fieldCaption">
																[headblv.jo_date;frm='dd/mm/yyyy';noerr]
																
															</td>
														  </tr>

														  <tr>
															<td class="fieldCaption" align="right">BL no.</td>
															<td class="fieldCaption">:</td>
															<td class="fieldCaption">
																[headblv.bl_no;noerr]
																
															</td>

														  </tr>

														  <tr>
															<td class="fieldCaption" align="right">Invoice no.</td>
															<td class="fieldCaption">:</td>
															<td class="fieldCaption">
																[headblv.invoice_no;noerr]
																 <!--input type="text" name="invoice_no" value="[headblv.invoice_no;noerr]" maxlength="255" size="31" class="input" disabled-->
															</td>
														  </tr>

														   <tr>
															<td class="fieldCaption" align="right">Vessel</td>
															<td class="fieldCaption">:</td>
															<td class="fieldCaption">
																[headblv.vessel;noerr]
																 <!--input type="text" name="vessel" value="[headblv.vessel;noerr]" maxlength="255" size="31" class="input" disabled-->
															</td>

														  </tr>

														  <tr>
															<td class="fieldCaption" align="right">Approval Status Job Order</td>
															<td class="fieldCaption">:</td>
															<td class="fieldCaption">
																[headblv.jo_appv_status]
															</td>
														  </tr>

														  <!--tr>
															<td class="fieldCaption" align="right">JO Costing Staff</td>
															<td class="fieldCaption">:</td>
															<td class="fieldCaption">

																<select name="receivedList" class="input" onchange="GetStaff('JOCostingFormHeader');">
																	<option value="" selected>Select Value</option>
																	<option value="2">Staff</option>
																</select>

																<input type="hidden" name="staff_jo_costing_id" value="[headblv.staff_jo_costing_id]" maxlength="255" size="25" class="input">
																<input type="text" name="staff_jo_costing_name" value="[headblv.staff_operasional;noerr]" maxlength="255" size="25" class="input" readonly>

															</td>
														  </tr-->
														  <tr>
															<td class="fieldCaption" align="right">Operation Staff</td>
															<td class="fieldCaption">:</td>
															<td class="fieldCaption">
																[headblv.operation_staff_name;noerr]

															</td>
														  </tr>

														  


													 </table>
													 <!-- END FORM SECTION -->
													 
													 
												</td>
												<!-- END FORM BLOCK -->
												
												
												<!-- FORM BLOCK -->
												<td valign="top">
												
												     <!--Cost-->
													 <table border="0" width="40%" cellpadding="3" cellspacing="1" class="FacetFormTABLEOperational" align="left" style="margin-bottom:20px;">
														<tr>
															<td colspan="3"> <b>COST</b>
															</td>
														</tr>
													   <tr>
															<td nowrap class="FacetColumnTDOperational" align="center" width="100">Currency</td>
															<td nowrap class="FacetColumnTDOperational" align="center" width="155">Cost Before Tax (CBT)</td>
															<td nowrap class="FacetColumnTDOperational" align="center" width="155">Cost After Tax (CAT)</td>
														</tr>
														<tr>
															<td nowrap class="FacetColumnTDOperational" align="center">IDR </td>
															<td nowrap class="FacetDataTDOperational" align="center"><input type="text" name="cbt_idr" value="[headblv.cbt_idr;noerr;frm='0,000.00']" size="15" class="input" readonly></td>
															<td nowrap class="FacetDataTDOperational" align="center"><input type="text" name="cat_idr" value="[headblv.cat_idr;noerr;frm='0,000.00']" size="15" class="input" readonly></td>
														</tr>
														<tr>
															<td nowrap class="FacetColumnTDOperational" align="center">USD </td>
															<td nowrap class="FacetDataTDOperational" align="center"><input type="text" name="cbt_usd" value="[headblv.cbt_usd;noerr;frm='0,000.00']" size="15" class="input" readonly></td>
															<td nowrap class="FacetDataTDOperational" align="center"><input type="text" name="cat_usd" value="[headblv.cat_usd;noerr;frm='0,000.00']" size="15" class="input" readonly></td>
														</tr>

													 </table>
													 <!--End Cost-->
												
												</td>
												<!-- END FORM BLOCK -->
												
										</tr>
												
												
								</table>

                         <h3>DATA CARGO</h3>

                             <div style="overflow:auto;height:auto;">
                             <table border="0" width="980px" cellpadding="3" cellspacing="1" class="FacetFormTABLEOperational" align="left">

                                <tr>                                        
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="35">No.</td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="200">Cargo Type</td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="70">Qty</td>
										<td nowrap class="FacetColumnTDOperational" align="center" width="150">Packages</td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="100">Weight (kg)</td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="100">Volume (cbm)</td>
                                        <td nowrap class="FacetColumnTDOperational" align="center">Remarks</td>
                                </tr>

                                <tr id="rowCargo[blgCargo.#]" style="display:[blgCargo._display;noerr]">


                                    <td nowrap class="FacetDataTDOperational" align="center">
                                      [blgCargo.#;block=tr].
                                      <input type="hidden" name="jo_id[blgCargo.#]" value="[tbs_check;if [var.jo_id;noerr]!='';then [var.jo_id;noerr] ;else '']">
                                    </td>

                                    <td nowrap class="FacetDataTDOperational" align="center">
                                       <select name="cargo_type[blgCargo.#]" class="input" disabled>
                                         <option value="">-</option>
                                         <option value="[CargoType.cargo_id]">[CargoType.cargo_name;block=option]</option>
                                         <option>[blgCargo.cargo_type;selected;noerr]</option>
                                       </select>
                                    </td>

                                    <td nowrap class="FacetDataTDOperational" align="center">
                                      <input type="text"  name="cargo_jumlah[blgCargo.#]" value="[blgCargo.cargo_jumlah;noerr]" id="input" size="4" disabled>
                                    </td>
									
									<td nowrap class="FacetDataTDOperational" align="center">
									  <input type="text"  name="cargo_pkgs[blgCargo.#]" value="[blgCargo.cargo_pkgs;noerr]" id="input" size="10" disabled>
									</td>

                                    <td nowrap class="FacetDataTDOperational" align="center">
                                      <input type="text"  name="cargo_berat[blgCargo.#]" value="[blgCargo.cargo_berat;noerr]" id="input" size="7" disabled>
                                    </td>

                                    <td nowrap class="FacetDataTDOperational" align="center">
                                      <input type="text"  name="cargo_volume[blgCargo.#]" value="[blgCargo.cargo_volume;noerr]" id="input" size="7" disabled>
                                    </td>

                                    <td nowrap class="FacetDataTDOperational" align="center">
                                      <input type="text"  name="cargo_lamp[blgCargo.#]" value="[blgCargo.cargo_lamp;noerr]" id="input" size="17" disabled>
                                    </td>


                                </tr>

                             </table>
                             </div>

                         </td>

                         

                         </tr>
                         </table>

                         <!--END TABLE MASTER-->

                                </td>
                            </tr>
                        </table>


                        <!--GRID-->

                        <hr size="1" color="DFDFDF">
                        <div id="spanHeader" style="height: 25px; vertical-align: top; overflow-y: noscroll;">
                        <table border="0" width="100%" cellpadding="3" cellspacing="1" class="FacetFormTABLEOperational" align="left">

                                <tr>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="25">X</td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="25">No.</td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="230">Services</td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="90">Qty Services</td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="230">Activities</td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="80"> Qty Activities</td>
                                        <!--td nowrap class="FacetColumnTDOperational" align="center"> Progress </td-->
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="200">Unit</td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="80">Currency</td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="90">Rate</td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="90">Amount</td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="90">Base Amount</td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="150">Tax Rate</td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="100">Tax Amount</td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" >Total Amount</td>
										<td nowrap class="FacetColumnTDOperational" align="center" width="230">Verifikator</td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="70">Ref</td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="230">Paid to</td>
										<td nowrap class="FacetColumnTDOperational" align="center" width="230">Date Needed</td>
										<td nowrap class="FacetColumnTDOperational" align="center" width="400">Remarks</td>
                                        <td nowrap class="FacetColumnTDOperational" align="center" width="200">Approval</td>                                        
										<td nowrap class="FacetColumnTDOperational" align="center" width="200">Action</td>
                                </tr>
                        </table>
                        </div>




                        <div id="spanDetail" class="tariffgrid" style="height: 200px; vertical-align: top; overflow: auto;">

                            <!--Edited by van Smith-->
							<input type=hidden name="activeRow" id="activeRow" value="">

                            <table border="0" width="100%" cellpadding="3" cellspacing="1" class="FacetFormTABLEOperational" align="left">

                                <tr id="jobCosting[blgJobCosting.#]" style="display:[blgJobCosting._display;noerr]">

                                        <td nowrap class="FacetDataTDOperational" align="center" width="25">
                                          <input type="checkbox" name="txtCheckJobCosting[blgJobCosting.#]" value="[blgJobCosting.jo_costing_id;noerr]" class="inputRadio[blgJobCosting.#]" >
                                          <input type=hidden name="dk[blgJobCosting.#]" value="D">
										  <input type=hidden name="costing_id[blgJobCosting.#]" value="[blgJobCosting.jo_costing_id;noerr]">
                                        </td>

                                    <td nowrap class="FacetDataTDOperational" align="center" width="25">
                                      [blgJobCosting.#;block=tr].
                                      <input type="hidden" name="jo_costing_id[blgJobCosting.#]" value="[tbs_check;if [var.jo_id;noerr]!='';then [var.jo_id;noerr] ;else '']">
                                    </td>

                                        <td nowrap class="FacetDataTDOperational" align="center" width="230">

                                           <select name="servicesList[blgJobCosting.#]" id="input" onchange="GetServices(this.value,'[blgJobCosting.#]');" class="servicesList[blgJobCosting.#]">
                                             <option value="" selected>Services</option>
                                             <option value="1">Select</option>
                                           </select>
                                           <input type="hidden" name="services_id[blgJobCosting.#]" id="services_id[blgJobCosting.#]" value="[blgJobCosting.services_id;noerr]" class="input">
                                           <input type="hidden" name="services_code[blgJobCosting.#]" value="[blgJobCosting.services_code;noerr]" class="input">
                                           <input type="hidden" name="disburgement[blgJobCosting.#]" value="[blgJobCosting.disburgement;noerr]" class="input">
                                           <input type="text" name="services_name[blgJobCosting.#]" value="[blgJobCosting.services_name;noerr]" maxlength="255" size="15"  class="input" readonly>
                                        </td>



                                        <td nowrap class="FacetDataTDOperational" align="center" width="90"><input type="text"  name="qty_service[blgJobCosting.#]" class="qty_service[blgJobCosting.#]" value="[blgJobCosting.qty_service;noerr]" id="input" size="5" readonly></td>

                                        <td nowrap class="FacetDataTDOperational" align="center" width="230">

                                           <select name="activitiesList[blgJobCosting.#]" class="activitiesList[blgJobCosting.#]" id="input" onchange="GetActivities(this.value,'[blgJobCosting.#]');">
                                             <option value="" selected>Activities</option>
                                             <option value="1">Select</option>
                                           </select>
                                           <input type="hidden" name="activities_id[blgJobCosting.#]" value="[blgJobCosting.activities_id;noerr]" class="input">
                                           <input type="hidden" name="activities_code[blgJobCosting.#]" value="[blgJobCosting.activities_code;noerr]" class="input">
                                           <input type="text" name="activities_name[blgJobCosting.#]" value="[blgJobCosting.actname;noerr]" maxlength="255" size="15" class="input" readonly>
                                        </td>

                                        <td nowrap class="FacetDataTDOperational" align="center" width="80">
                                            <input type="text" name="qty_activity[blgJobCosting.#]" value="[blgJobCosting.qty_activity;noerr]" onkeyup="getBaseAmount('[blgJobCosting.#]'); maskMode(this.name,this.value);" class="gridBox qty_activity[blgJobCosting.#]" id="input" size="5" >
                                            <input type="hidden"  name="qty_activity_remain[blgJobCosting.#]" value="[blgJobCosting.qty_activity_remain;noerr]" id="input" size="5" >
                                        </td>

                                       

                                        <td nowrap class="FacetDataTDOperational" align="center" width="200">
                                           <select name="unit[blgJobCosting.#]" id="input" class="unit[blgJobCosting.#]">
                                             <option value="">-</option>
                                             <option value="[unit.unit_code]">[unit.unit_name;block=option]</option>
                                             <option>[blgJobCosting.unit;selected;noerr]</option>
                                           </select>
                                        </td>
                                        <td nowrap class="FacetDataTDOperational" align="center" width="80">

                                           <select name="curr[blgJobCosting.#]" id="input" onchange="getBaseAmount('[blgJobCosting.#]');" class="curr[blgJobCosting.#]">
                                              <option value="">-</option>
                                              <option value="IDR">IDR</option>
                                              <option value="USD">USD</option>
                                              <option>[blgJobCosting.curr;selected;noerr]</option>
                                           </select>
                                        </td>
                                        <td nowrap class="FacetDataTDOperational" align="center" width="90"><input type="text"  name="rate[blgJobCosting.#]" value="[blgJobCosting.rate;noerr;frm='0,000.00']" id="input" class="rate[blgJobCosting.#]" onkeyup="getBaseAmount('[blgJobCosting.#]'); maskMode(this.name, this.value); " size="8"></td>
                                        <td nowrap class="FacetDataTDOperational" align="center" width="90">
                                            <input type="text"  name="amount[blgJobCosting.#]" value="[blgJobCosting.amount;noerr;frm='0,000.00']" id="input" size="10" class="amount amount[blgJobCosting.#]" readonly>
                                            <input type="hidden"  name="amount_remain[blgJobCosting.#]"  id="input" size="8" readonly>
                                        </td>
                                        <td nowrap class="FacetDataTDOperational" align="center" width="90"><input type="text"  name="base_amount[blgJobCosting.#]" class="base_amount[blgJobCosting.#]" value="[blgJobCosting.base_amount;noerr;frm='0,000.00']" id="input" size="8" readonly></td>
                                        <td nowrap class="FacetDataTDOperational" align="center" width="150">

                                           <select name="tax_rate[blgJobCosting.#]" class="tax_rate[blgJobCosting.#]" id="input" onchange="getBaseAmount('[blgJobCosting.#]');">
                                             <option value="">-</option>
                                             <option value="[taxRate.calculate]-[taxRate.tax_kind]">[taxRate.description;block=option] - [taxRate.tax_kind]</option>
                                             <option>[blgJobCosting.tax_rate;selected;noerr]</option>
                                           </select>

                                        </td>
                                        <td nowrap class="FacetDataTDOperational" align="center" width="100">
                                            <input type="text"  name="tax_amount[blgJobCosting.#]" class="tax_amount[blgJobCosting.#]" value="[blgJobCosting.tax_amount;noerr;frm='0,000.00']" id="input" size="8" readonly>
                                            <input type="hidden" name="tax_amount_usd[blgJobCosting.#]" value="[blgJobCosting.tax_amount_usd;noerr;]" id="input" size="12" readonly>
                                        </td>
                                        <td nowrap class="FacetDataTDOperational" align="center"  width="100">
                                            <input type="text"  name="total_amount[blgJobCosting.#]" class="total_amount[blgJobCosting.#]" value="[blgJobCosting.total_amount;noerr;frm='0,000.00']" id="input" size="11" readonly>
                                            <input type="hidden" name="total_amount_usd[blgJobCosting.#]" value="[blgJobCosting.total_amount_usd;noerr;]" id="input" size="16" readonly>
                                            <input type="hidden"  name="budget_remain[blgJobCosting.#]" value="[blgJobCosting.budget_remain;noerr]" id="input" size="16" readonly>
                                            <input type="hidden"  name="budget_ap_remain[blgJobCosting.#]" value="[blgJobCosting.budget_ap_remain;noerr]" id="input" size="16" readonly>
                                        </td>
										
										<td nowrap class="FacetDataTDOperational" align="center" width="230">                                           
                                           <select name="paid_verify[blgJobCosting.#]" class="paid_verify[blgJobCosting.#]" id="input" onchange="GetStaffGrid('jo_costing_verifikator', '[blgJobCosting.#]');">
                                            <option value="" selected>-</option>
                                            <option value="2">select</option>
                                           </select>

                                           <input type="hidden" name="verifikator[blgJobCosting.#]" value="[blgJobCosting.verifikator;noerr]" maxlength="255" size="15" class="input">
                                           <input type="text" name="verifikator_name[blgJobCosting.#]" class="verifikator_name[blgJobCosting.#]" value="[blgJobCosting.verifikator_name;noerr]" maxlength="255" size="15" id="input" readonly>
                                        </td>

                                        <td nowrap class="FacetDataTDOperational" align="center" width="70">
                                           <select name="paid_ref[blgJobCosting.#]" class="paid_ref[blgJobCosting.#]" id="input" onchange="">
                                             <option value="" selected>-</option>
                                             <option value="vendor">Vendor</option>
                                             <option value="staff">Staff</option>
                                             <option>[blgJobCosting.paid_ref;selected;noerr]</option>
                                           </select>
                                        </td>

                                        <td nowrap class="FacetDataTDOperational" align="center" width="230">
                                           <select name="paid_to[blgJobCosting.#]" class="paid_to[blgJobCosting.#]" id="input" onchange="CheckPaidRef('jo_costing_paid_to', '[blgJobCosting.#]');">
                                            <option value="" selected>-</option>
                                            <option value="2">select</option>
                                           </select>

                                           <input type="hidden" name="paid_to_code[blgJobCosting.#]" value="[blgJobCosting.paid_to_code;noerr]" maxlength="255" size="15" class="input">
                                           <input type="text" name="paid_to_name[blgJobCosting.#]" value="[tbs_check;if [blgJobCosting.paid_ref;noerr]='vendor';then [blgJobCosting.CUNAME;noerr] ;else [blgJobCosting.staff_paid_to;noerr];noerr]" maxlength="255" size="15" class="input" readonly>
                                        </td>
										
										
										<td nowrap class="FacetDataTDOperational" align="center" width="230">
										    <input type="text" name="date_needed[blgJobCosting.#]"  maxlength="255" size="12" class="input" value="[tbs_check;if [blgJobCosting.date_needed;frm='dd/mm/yyyy';noerr]!='';then [blgJobCosting.date_needed;frm='dd/mm/yyyy';noerr]; else [sys.now;frm='dd/mm/yyyy']]" class="input" >
											<a href="javascript:void(0)" onclick="gfPop.fPopCalendar([var.HTMLFormName].date_needed[blgJobCosting.#]);return false;" hidefocus>
											<img name="popcal" align="absMiddle" src="[var.ROOT_DIR]js/Calendar/pop/calbtn.gif" width="34" height="22" border="0" alt=""></a> 
										</td>
										
										<td nowrap class="FacetDataTDOperational" align="center" width="400">
										    <input type="text" name="jobcosting_remark[blgJobCosting.#]" value="[blgJobCosting.jobcosting_remark;noerr]" id="input" size="40" >
										</td>
										
                                        
                                        <td nowrap class="FacetDataTDOperational" align="center" width="200">
                                           <select name="jo_costing_appv_status[blgJobCosting.#]" id="input" class="approve_status">
												  <option value="">-</option>
												  <option value="draft">Draft</option>
												  <option value="wait_approved">Waiting for Approval</option>
												  
												  <option>
												          [tbs_check;if [blgJobCosting.jo_costing_appv_status]=='draft';
												          then 'draft' ;else '';selected;noerr]
												  </option>
												  
												  <option>
												          [tbs_check;if [blgJobCosting.jo_costing_appv_status]=='wait_approved';
												          then 'wait_approved' ;else '';selected;noerr]
												  </option>
												  												  
												  [tbs_check;htmlconv=no;if [blgJobCosting.jo_costing_appv_status]=='approved_1';
												  then '<option value="approved_1" selected>Approve 1</option>' ;else '';noerr]
												   			  
												  [tbs_check;htmlconv=no;if [blgJobCosting.jo_costing_appv_status]=='approved_2';
												  then '<option value="approved_2" selected>Approve 2</option>' ;else '';noerr]
								
										   </select>
                                        </td>
										<td nowrap class="FacetDataTDOperational" align="center" width="70">
                                            <!--a href="[sys.script_name]?PageMode=Form&jo_id=[blg.jo_id]&row=[blgJobCosting.#]&jo_costing_id=[blgJobCosting.jo_costing_id;noerr]&project_id=[blg.project_id;noerr]">Save</a-->
                                            <!--input name="FormAction" type="submit" value="Save" class="button" onClick="return CheckAll();"-->
                                            <input name="FormAction" type="submit" value="Save" id="button[blgJobCosting.#]" class="button" id="active[blgJobCosting.#]" onClick="return getActiveRow(this);">
                                        </td>
                                        </form>
                                        
                                                    
                                        
                                        
                                    </tr>
                            </table>

                            <!--End Edited by van Smith-->

                        </div>

                        <!--END GRID-->






                        <!--BUTTON-->
                        <div id="spanButton" style="height: 35px; vertical-align: top; overflow-y: noscroll;">
                        <table border="0" width="100%" cellpadding="3" cellspacing="1" class="FacetFormTABLEOperational" align="left">
                                <tr>
                                    <td align="right" class="FacetColumnTDOperational">

                                           <table border="0" cellspacing="2" cellpadding="0">
                                                   <tr>
                                                           <td>
                                                             <input name="FormAction" type="button" value="Next Line" class="button" onClick="return (AddFormGridProject(this,'[var.HTMLFormName].qty_activity'))">
                                                           </td>
                                                           <td>[tbs_check;block=td;if [var.USER_CANUPDATE]=1]
                                                                <input name="FormAction" type="button" value="Delete Line" class="button" onClick="DeleteLines()">
                                                            </td>
                                                           <td>
                                                             <!--input name="FormAction" type="submit" value="Save" class="button" onClick="if(CheckAll();){this.form.submitted = true; return true;}"-->
                                                             <!--input name="FormAction" type="submit" value="Save" class="button" onClick="return CheckAll();"-->
                                                           </td>
                                                           
                                                           <td>
                                                             <input name="FormAction" type="submit" value="Cancel" class="button" onClick="self.location.replace('[sys.script_name]')">
                                                           </td>
                                                   </tr>
                                           </table>


                                    </td>
                                        </td>
                                </tr>

                        </table>
                        </div>

                        <!--END BUTTON-->


                    </td>
                </tr>

                <!--/form-->

            </table>
            </td>
        </tr>
        <tr>
            <td>
            <br>
            <table border="0" cellspacing="0" cellpadding="0" width="100%">
                <tr>
                    <td class="footer1"><img src="images/spacer.gif" height="1" width="1"></td>
                </tr>
                <!--tr>
                    <td class="footer2">Prototype Test - Web Application</td>
                </tr-->
            </table>
            </td>
        </tr>
    </table>
 </body>


 <iframe width="174" height="189" name="gToday:normal:agenda.js" id="gToday:normal:agenda.js" src="[var.ROOT_DIR]js/Calendar/pop/ipopeng.htm" scrolling="no" frameborder="0" style="LEFT: -500px; POSITION: absolute; TOP: 0px; VISIBILITY: visible; Z-INDEX: 999"></iframe>

 <script>
 $(function() {
    
     GetCostandPL();
     DisableApproved();
 });

 [var.InitFunction]




 SetDK(1,'K');

 document.[var.HTMLFormName].total_trans.value = SumTotal("jumlah");


function getActiveRow(test){
        var id = test.id;
        id = id.substr(-1);
        //alert(id);
        $("input[name=activeRow]").val(id);
        return true;
}

function IsNumeric(sText)
{
   var ValidChars = "0123456789.,";
   var IsNumber=true;
   var Char;


   for (i = 0; i < sText.length && IsNumber == true; i++)
      {
      Char = sText.charAt(i);
      if (ValidChars.indexOf(Char) == -1)
         {
         IsNumber = false;
         }
      }
   return IsNumber;

}

function CheckAll(){
    var n=0;
    var var_total_amont = 0;
    var var_paid_to_name = "";
    var var_paid_ref = "";
    var var_jo_costing_appv_status = "";
    //var var_staff_jo_costing_name = "";
    var errMsg = "";

    //$("input[name=base_amount"+urut+"]").val();

    //var_staff_jo_costing_name = $("input[name=staff_jo_costing_name]").val();
    var_jo_costing_appv_status = $("select[name=jo_costing_appv_status]").val();


    //if (var_staff_jo_costing_name == ""){
      //  errMsg = "- Field \'JO Costing Staff\' tidak boleh kosong \n";
    //}


    if (var_jo_costing_appv_status == ""){
        errMsg = errMsg + "- Field \'Approval Status Job Costing\' tidak boleh kosong \n";
    }


    $(".gridBox:visible").each(function(n) {
        n = n+1;
        var_total_amount = $("input[name=total_amount"+n+"]").val();
        var_paid_to_name = $("input[name=paid_to_name"+n+"]").val();
        var_paid_ref = $("select[name=paid_ref"+n+"]").val();

        if (var_total_amount != "" && var_paid_ref == ""){
            errMsg = errMsg + "- Kolom \'ref\' pada baris ke-"+n+" tidak boleh kosong \n";
            //alert ("Kolom ref pada baris ke-"+n+"tidak boleh kosong");
        }

        if (var_total_amount != "" && var_paid_ref != "" && var_paid_to_name== ""){
            errMsg = errMsg + "- Kolom \'Paid to\' pada baris ke-"+n+" tidak boleh kosong \n";
            //alert ("Kolom \"Paid to\" pada baris ke-"+n+"tidak boleh kosong");
        }
    });

    //alert(errMsg);

    if (errMsg == ""){
        //alert("loh kok masuk");
        return true;
    } else {
        alert(errMsg);
        return false;
    }
    //return false;
}

function getBaseAmount(urut){

    oMask = new Mask('#,###.#0', 'number');


   var qty_activity = eval("document.[var.HTMLFormName].qty_activity"+urut+".value");
   var rate = eval("document.[var.HTMLFormName].rate"+urut+".value");
   var curr = eval("document.[var.HTMLFormName].curr"+urut+".value");
   var tax_rate = eval("document.[var.HTMLFormName].tax_rate"+urut+".value");
   var amount = 0;
   var baseAmount = 0;
   var tax_amount = 0;
   var tax_amount_usd = 0;
   var total_amount = 0;
   var total_amount_usd = 0;

   var maskcbt_idr = 0;
   var maskcbt_usd = 0;
   var maskcat_idr = 0;

   var rbt_idr = 0;
   var rbt_usd = 0;
   var rat_idr = 0;
   var rat_usd = 0;

   var cbt_idr = 0;
   var cbt_usd = 0;
   var cat_idr = 0;
   var cat_usd = 0;

   var plbt_idr = 0;
   var plat_usd = 0;
   var plat_idr = 0;

   var amountCounter = 0;
   var totalAmountCounter = 0;
   var currCounter = "";

   var survey_idr = 0;
   var survey_usd = 0;
   var survey_total = 0;

    $("input[name=qty_activity_remain"+urut+"]").val(qty_activity);

   

   //Parse the Tax
   var tax_arr = tax_rate.split("-");

   var tax_val = parseFloat(tax_arr[0]);
   var tax_text = tax_arr[1];
   //End Parse the Tax

   /*var counter = 0;
   var n = 0;
   var reccount = 0;
   var amount = 0;
   var baseAmount = 0;
   var tax_amount = 0;
   var total_amount = 0;
*/
   //error handling for rate
   if(rate == "") rate = 0;
   else if (!IsNumeric(rate)) alert('Rate should be Numeric value');

   //error handling for Quantity
   if(qty_activity == "") qty_activity = 0;
   else if (!IsNumeric(qty_activity)) alert('Quantity should be Numeric value');

   //error handling for Tax Rate
   if(tax_rate == "") tax_rate = 0;

   //Parse to Integer
   //qty_activity = parseInt(qty_activity);
   //rate = parseInt(rate);
	qty_activity = String(qty_activity);
       qty_activity = (qty_activity.replace(/,/g, "")) * 1;
	
   if(curr == "IDR")
   {
       rate = String(rate);
       rate = (rate.replace(/,/g, "")) * 1;
       

      baseAmount = qty_activity * rate;
      amount = qty_activity * rate;
	  //alert(amount + " & " + qty_activity + " & " + rate);  	  
   }

   else if(curr == "USD")
   {
      rate = String(rate);
      rate = (rate.replace(/,/g, "")) * 1;

      baseAmount = qty_activity * rate * [var.kursUSD];
      amount = qty_activity * rate;
   }

   //Counting the Tax
   ///tax_amount = baseAmount * tax_rate;

   //Counting the Total
   ///total_amount = baseAmount + tax_amount;

    if(tax_text == "exclude")
   {
     if(curr == "IDR")
     {

         baseAmount = String(baseAmount);
         baseAmount = (baseAmount.replace(/,/g, "")) * 1;
         tax_amount = baseAmount * tax_val;
         tax_amount_usd = 0;

         tax_amount = String(tax_amount);
         tax_amount = (tax_amount.replace(/,/g, "")) * 1;
         total_amount = baseAmount + tax_amount;
         total_amount_usd = 0;

     }  else if(curr == "USD")

     {
         baseAmount = String(baseAmount);
         baseAmount = (baseAmount.replace(/,/g, "")) * 1;
         tax_amount = amount * tax_val * [var.kursUSDTax];
         tax_amount_usd = amount * tax_val.toFixed(2);

         tax_amount = String(tax_amount);
         tax_amount = (tax_amount.replace(/,/g, "")) * 1;
         total_amount = baseAmount + tax_amount;
         total_amount_usd = amount + tax_amount_usd;
         total_amount_usd.toFixed(2);
     }
   }


   else if(tax_text == "include")
   {
     if(curr == "IDR")
     {

         amount = String(amount);
         amount = (amount.replace(/,/g, "")) * 1;

         tax_amount = 0.1/(1.1 - tax_val) * amount;
         tax_amount = tax_amount.toFixed(2);
         tax_amount_usd = 0;

         total_amount = baseAmount;
         total_amount_usd = 0;

     }   else if(curr == "USD")

     {

         amount = String(amount);
         amount = (amount.replace(/,/g, "")) * 1;

         tax_amount = 0.1/(1.1 - tax_val) * amount * [var.kursUSDTax];
         tax_amount = tax_amount.toFixed(2);
         tax_amount_usd = 0.1/(1.1 - tax_val) * amount;
         tax_amount_usd = tax_amount_usd.toFixed(2);

         total_amount = baseAmount;
         total_amount_usd = amount.toFixed(2);

     }


   }

   else
   {

     if(curr == "IDR")
     {

         baseAmount = String(baseAmount);
         baseAmount = (baseAmount.replace(/,/g, "")) * 1;
         total_amount = baseAmount;
         total_amount_usd = 0;

     }

     else if(curr == "USD")
     {
         baseAmount = String(baseAmount);
         baseAmount = (baseAmount.replace(/,/g, "")) * 1;
         total_amount = baseAmount;
         total_amount_usd = amount;
     }

   }

//return oMask.format(sum_all);


    //Change to Mask Format --Start--
    var maskBaseAmount = oMask.format(baseAmount);
    var maskAmount = oMask.format(amount);
    var maskTaxAmount = oMask.format(tax_amount);
    var maskTaxAmountUsd = oMask.format(tax_amount_usd);
    var maskTotalAmount = oMask.format(total_amount);
    var maskTotalAmountUsd = oMask.format(total_amount_usd);
    //Change to Mask Format --End--


   
   $("input[name=base_amount"+urut+"]").val(maskBaseAmount);
   $("input[name=amount"+urut+"]").val(maskAmount);
   $("input[name=tax_amount"+urut+"]").val(maskTaxAmount);
   $("input[name=tax_amount_usd"+urut+"]").val(maskTaxAmountUsd);
   $("input[name=total_amount"+urut+"]").val(maskTotalAmount);
   $("input[name=total_amount_usd"+urut+"]").val(maskTotalAmountUsd);
   $("input[name=amount_remain"+urut+"]").val(maskAmount);


   if(curr == "IDR"){
    $("input[name=budget_remain"+urut+"]").val(maskTotalAmount);
    $("input[name=budget_ap_remain"+urut+"]").val(maskTotalAmount);
   } else {
    $("input[name=budget_remain"+urut+"]").val(maskTotalAmountUsd);
    $("input[name=budget_ap_remain"+urut+"]").val(maskTotalAmountUsd);
   }

   
    //Count The CBT and CAT
    $(".amount:visible").each(function(n) {
      n = n+1;
      reccount = n;
      counter = this.name;
      counter = counter.substring(6);

      eval("amountCounter = document.[var.HTMLFormName].amount"+counter+".value");
      eval("totalAmountCounter = document.[var.HTMLFormName].total_amount"+counter+".value");
      eval("currCounter = document.[var.HTMLFormName].curr"+counter+".value");

      eval("taxCounter = document.[var.HTMLFormName].tax_amount"+counter+".value");
      eval("taxUSDCounter = document.[var.HTMLFormName].tax_amount_usd"+counter+".value");
      eval("totalAmountUSDCounter = document.[var.HTMLFormName].total_amount_usd"+counter+".value")

      amountCounter = String(amountCounter);
      amountCounter = (amountCounter.replace(/,/g, "")) * 1;

      taxCounter = String(taxCounter);
      taxCounter = (taxCounter.replace(/,/g, "")) * 1;

      totalAmountCounter = String(totalAmountCounter);
      totalAmountCounter = (totalAmountCounter.replace(/,/g, "")) * 1;

      taxUSDCounter = String(taxUSDCounter);
      taxUSDCounter = (taxUSDCounter.replace(/,/g, "")) * 1;

      totalAmountUSDCounter = String(totalAmountUSDCounter);
      totalAmountUSDCounter = (totalAmountUSDCounter.replace(/,/g, "")) * 1;


       if(currCounter == "IDR")
       {
          //amountCounter = parseInt(amountCounter);
            //amountCounter = String(amountCounter);
            //amountCounter = (amountCounter.replace(/,/g, "")) * 1;
          //amountCounter = oMask.format(amountCounter);


          if((amountCounter != "") || (amountCounter != "NaN"))
          {
            //cbt_idr+= amountCounter;
            //cbt_idr+= totalAmountCounter - taxCounter;
            cbt_idr+= totalAmountCounter - taxCounter;
          }
          else
          {
            cbt_idr+= 0;
          }
       }

       else if(currCounter == "USD")
       {
            //amountCounter = String(amountCounter);
            //amountCounter = (amountCounter.replace(/,/g, "")) * 1;

          if((amountCounter != "") || (amountCounter != "NaN"))
          {
            //cbt_usd+= amountCounter;
            //cbt_usd+= totalAmountUSDCounter - taxUSDCounter;
            cbt_usd+= totalAmountUSDCounter - taxUSDCounter;
          }
          else
          {
            cbt_usd+= 0 ;
          }
       }

       /*else if (currCounter == ""){
            cbt_idr+= 0 + survey_idr;
            cbt_usd+= 0 + survey_usd;
       }*/


       if(totalAmountCounter != "")
       {
         //totalAmountCounter = parseInt(totalAmountCounter);
            //totalAmountCounter = String(totalAmountCounter);
            //totalAmountCounter = (totalAmountCounter.replace(/,/g, "")) * 1;

         //alert(totalAmountCounter);

         //cat_idr+= totalAmountCounter;
         cat_idr+= totalAmountCounter;
       }
       else
       {
         cat_idr+= 0;
       }
   });

   
   eval("document.[var.HTMLFormName].cat_usd.value = 0");
   
   change_color(cbt_idr,'cbt_idr');
   change_color(cbt_usd,'cbt_usd');
   change_color(cat_idr,'cat_idr');
   change_color(cat_usd,'cat_usd');
   
   maskcbt_idr = oMask.format(cbt_idr);
   maskcbt_usd = oMask.format(cbt_usd);
   maskcat_idr = oMask.format(cat_idr);

   $("input[name=cbt_idr]").val(maskcbt_idr);
   $("input[name=cbt_usd]").val(maskcbt_usd);
   $("input[name=cat_idr]").val(maskcat_idr);

   //END Count The CBT and CAT

   
}


function GetSurveyCost(svidr, svusd, svtotal){
      var svidr = 0;
      var svusd = 0;
      var svtotal = 0;
      var cbt_idr = 0;
      var cbt_usd = 0;
      var cat_idr = 0;

    $(".survey_total_amount:visible").each(function(n) {
      counter = this.name;
      counter = counter.substring(19);


      eval("amountCounter = document.[var.HTMLFormName].survey_amount"+counter+".value");
      eval("totalAmountCounter = document.[var.HTMLFormName].survey_total_amount"+counter+".value");
      eval("currCounter = document.[var.HTMLFormName].survey_curr"+counter+".value");

      eval("taxCounter = document.[var.HTMLFormName].survey_tax_amount"+counter+".value");
      eval("taxUSDCounter = document.[var.HTMLFormName].survey_tax_amount_usd"+counter+".value");
      eval("totalAmountUSDCounter = document.[var.HTMLFormName].survey_total_amount_usd"+counter+".value")



      amountCounter = String(amountCounter);
      amountCounter = (amountCounter.replace(/,/g, "")) * 1;

      taxCounter = String(taxCounter);
      taxCounter = (taxCounter.replace(/,/g, "")) * 1;

      totalAmountCounter = String(totalAmountCounter);
      totalAmountCounter = (totalAmountCounter.replace(/,/g, "")) * 1;

      taxUSDCounter = String(taxUSDCounter);
      taxUSDCounter = (taxUSDCounter.replace(/,/g, "")) * 1;

      totalAmountUSDCounter = String(totalAmountUSDCounter);
      totalAmountUSDCounter = (totalAmountUSDCounter.replace(/,/g, "")) * 1;


       if(currCounter == "IDR")
       {
          if((amountCounter != "") || (amountCounter != "NaN"))
          {
            cbt_idr+= totalAmountCounter - taxCounter;
          }
          else
          {
            cbt_idr+= 0;
          }

       }

       else if(currCounter == "USD")
       {
            //amountCounter = String(amountCounter);
            //amountCounter = (amountCounter.replace(/,/g, "")) * 1;

          if((amountCounter != "") || (amountCounter != "NaN"))
          {
            //cbt_usd+= amountCounter;
            cbt_usd+= totalAmountUSDCounter - taxUSDCounter;
          }
          else
          {
            cbt_usd+= 0;
          }
       }

       if(totalAmountCounter != "")
       {
         //totalAmountCounter = parseInt(totalAmountCounter);
            //totalAmountCounter = String(totalAmountCounter);
            //totalAmountCounter = (totalAmountCounter.replace(/,/g, "")) * 1;

         //alert(totalAmountCounter);

         cat_idr+= totalAmountCounter;
       }
       else
       {
         cat_idr+= 0;
       }
   });

   //svidr = cbt_idr;
   //svusd = cbt_usd;
   //svtotal = cat_idr;

   var survey = new Array();
   survey[0] = cbt_idr;
   survey[1] = cbt_usd;
   survey[2] = cat_idr;

   return survey;
}


 function GetCostandPL() {

    oMask = new Mask('#,###.#0', 'number');

    var plbt_idr = 0;
    var plbt_usd = 0;
    var plat_idr = 0;
    var plat_usd = 0;
    var amount = 0;
    var baseAmount = 0;
    var tax_amount = 0;
    var total_amount = 0;
    var cbt_idr = 0;
    var cbt_usd = 0;
    var cat_idr = 0;
    var cat_usd = 0;
    var amountCounter = 0;
    var totalAmountCounter = 0;
    var currCounter = "";

    var survey_idr = 0;
    var survey_usd = 0;
    var survey_total = 0;

    

    //Count The CBT and CAT
    $(".amount:visible").each(function(n) {

      n = n+1;
      reccount = n;
      counter = this.name;
      counter = counter.substring(6);

      eval("amountCounter = document.[var.HTMLFormName].amount"+counter+".value");
      eval("totalAmountCounter = document.[var.HTMLFormName].total_amount"+counter+".value");
      eval("currCounter = document.[var.HTMLFormName].curr"+counter+".value");

      eval("taxCounter = document.[var.HTMLFormName].tax_amount"+counter+".value");
      eval("taxUSDCounter = document.[var.HTMLFormName].tax_amount_usd"+counter+".value");
      eval("totalAmountUSDCounter = document.[var.HTMLFormName].total_amount_usd"+counter+".value")


      amountCounter = String(amountCounter);
      amountCounter = (amountCounter.replace(/,/g, "")) * 1;

      taxCounter = String(taxCounter);
      taxCounter = (taxCounter.replace(/,/g, "")) * 1;

      totalAmountCounter = String(totalAmountCounter);
      totalAmountCounter = (totalAmountCounter.replace(/,/g, "")) * 1;

      taxUSDCounter = String(taxUSDCounter);
      taxUSDCounter = (taxUSDCounter.replace(/,/g, "")) * 1;

      totalAmountUSDCounter = String(totalAmountUSDCounter);
      totalAmountUSDCounter = (totalAmountUSDCounter.replace(/,/g, "")) * 1;

       if(currCounter == "IDR")
       {
          
          if((amountCounter != "") || (amountCounter != "NaN"))
          {
            //cbt_idr+= amountCounter;
            cbt_idr+= totalAmountCounter - taxCounter;
          }
          else
          {
            cbt_idr+= 0;
          }
          //alert(cbt_idr);
       }

       else if(currCounter == "USD")
       {
          
          if((amountCounter != "") || (amountCounter != "NaN"))
          {
            //cbt_usd+= amountCounter;
            cbt_usd+= totalAmountUSDCounter - taxUSDCounter;
          }
          else
          {
            cbt_usd+= 0;
          }
       }

       

       if(totalAmountCounter != "")
       {        
         cat_idr+= totalAmountCounter;
       }
       else
       {
         cat_idr+= 0;
       }
   });


    //cat_idr = cat_idr + survey_total;



   eval("document.[var.HTMLFormName].cat_usd.value = 0");
   
   change_color(cbt_idr,'cbt_idr');
   change_color(cbt_usd,'cbt_usd');
   change_color(cat_idr,'cat_idr');
   change_color(cat_usd,'cat_usd');

   maskcbt_idr = oMask.format(cbt_idr);
   maskcbt_usd = oMask.format(cbt_usd);
   maskcat_idr = oMask.format(cat_idr);

   $("input[name=cbt_idr]").val(maskcbt_idr);
   $("input[name=cbt_usd]").val(maskcbt_usd);
   $("input[name=cat_idr]").val(maskcat_idr);

   //END Count The CBT and CAT


   cbt_idr = document.JobCostingForm.cbt_idr.value;
   cbt_idr = String(cbt_idr);
   cbt_idr = (cbt_idr.replace(/,/g, "")) * 1;


   cbt_usd = document.JobCostingForm.cbt_usd.value;
   cbt_usd = String(cbt_usd);
   cbt_usd = (cbt_usd.replace(/,/g, "")) * 1;


   cat_idr = document.JobCostingForm.cat_idr.value;
   cat_idr = String(cat_idr);
   cat_idr = (cat_idr.replace(/,/g, "")) * 1;

  

 }
 
 
 function change_color(val,element)
 {
	 
     if(val == 0)
     {
	     $("input[name="+element+"]").attr('id','cost_val_black');
     }
   
     else if(val > 0 && val < 15000000)
     {
	     $("input[name="+element+"]").attr('id','cost_val_green');
     }
   
     else
     {
	     $("input[name="+element+"]").attr('id','cost_val_red');
     }
	 
 }
 
 
 
 function DisableApproved() {
 
    $(".approve_status:visible").each(function(n) {

      counter = this.name;
      counter = counter.substring(22);

      eval("approval_status = document.[var.HTMLFormName].jo_costing_appv_status"+counter+".value");
      
     
      if(approval_status == 'wait_approved' || approval_status == 'approved_1' || approval_status == 'approved_2' )
      {
		   
		   eval("$('.inputRadio"+counter+"').attr('disabled', 'disabled');");
		   eval("$('.servicesList"+counter+"').attr('disabled', 'disabled');");
		   //eval("$('.qty_service"+counter+"').attr('disabled', 'disabled');");
		   eval("$('.activitiesList"+counter+"').attr('disabled', 'disabled');");
		   eval("$('.qty_activity"+counter+"').attr('readonly', 'readonly');");		   		   
		   //eval("$('.unit"+counter+"').attr('disabled', 'disabled');");
		   //eval("$('.curr"+counter+"').attr('disabled', 'disabled');");		   
		   //eval("$('.rate"+counter+"').removeAttr('readonly');");
		   eval("$('.rate"+counter+"').attr('readonly', 'readonly');");
		   //eval("$('.amount"+counter+"').removeAttr('readonly');");
		   //eval("$('.amount"+counter+"').attr('disabled', 'disabled');");
		   //eval("$('.base_amount"+counter+"').removeAttr('readonly');");
		   //eval("$('.base_amount"+counter+"').attr('disabled', 'disabled');");
		   //eval("$('.tax_amount"+counter+"').removeAttr('readonly');");
		   //eval("$('.tax_amount"+counter+"').attr('disabled', 'disabled');");
		   //eval("$('.total_amount"+counter+"').removeAttr('readonly');");
		   //eval("$('.total_amount"+counter+"').attr('disabled', 'disabled');");		   		   		   		   
		   //eval("$('.tax_rate"+counter+"').attr('disabled', 'disabled');");
		   eval("$('.paid_verify"+counter+"').attr('disabled', 'disabled');");
		   //eval("$('.paid_ref"+counter+"').attr('disabled', 'disabled');");
		   eval("$('.paid_to"+counter+"').attr('disabled', 'disabled');");
		   
	  }
      
       
   });


 }
 
 



 function GetServices(val,no_urut) {
      var jo_id = document.getElementById("jo_id").value;
      newwin = window.open("ais_transaction_serviceslist.php?FormName=[var.HTMLFormName]&SendToBack=1&PageMode=JobCostingForm&no_urut="+ no_urut + "&jo_id=" + jo_id, "toolcalc","height=400,width=640,noscroll,resizable");
 }

 function GetActivities(val,no_urut) {

      eval("service_id = document.getElementById('services_id" + no_urut +"').value");
      ("test: " + service_id);
      //var service_id = document.getElementById("services_id").value;
      //services_id[blg.#]
      newwin = window.open("ais_transaction_actnrlist.php?FormName=[var.HTMLFormName]&SendToBack=1&PageMode=JobCostingForm&no_urut="+ no_urut + "&service_id=" + service_id, "toolcalc","height=400,width=640,noscroll,resizable");
 }

 function GetReceived(val,no_urut) {
      newwin = window.open("ais_transaction_custlist_2.php?FormName=[var.HTMLFormName]&no_urut="+no_urut,"toolcalc","height=400,width=640,noscroll,resizable");
 }

 function GetStaff(need_another_var) {
            newwin = window.open("ais_transaction_stafflist.php?FormName=[var.HTMLFormName]&need_another_var="+need_another_var,"toolcalc","height=400,width=640,noscroll,resizable");
 }

  function GetStaffGrid(need_another_var, no_urut) {
            newwin = window.open("ais_transaction_stafflist.php?FormName=[var.HTMLFormName]&PageMode=JobCostingForm&need_another_var="+need_another_var+"&no_urut="+ no_urut,"toolcalc","height=400,width=640,noscroll,resizable");
 }

  function GetCustGrid(need_another_var, no_urut) {
            newwin = window.open("ais_transaction_custlist.php?FormName=[var.HTMLFormName]&PageMode=JobCostingForm&need_another_var="+need_another_var+"&no_urut="+ no_urut,"toolcalc","height=400,width=640,noscroll,resizable");
 }

 function CheckPaidRef(need_another_var, no_urut){
    //document.JobCostingForm.paid_ref1.value;
    //$("select[name=paid_ref1]").val();
    //eval("paid_ref_value = document.getElementById('services_id" + no_urut +"').value");

    eval("var paid_ref_value = document.[var.HTMLFormName].paid_ref"+no_urut+".value;");

    if(paid_ref_value == "vendor") {
        GetCustGrid(need_another_var, no_urut);
    } else if(paid_ref_value == "staff") {
        GetStaffGrid(need_another_var, no_urut);
    } else {
        alert("Harap mengisi kolom \"Paid_ref\" terlebih dahulu");
    }
 }

 function GetJo() {
            //newwin = window.open("ais_transaction_jolist.php?FormName=[var.HTMLFormName]&need_another_var="+need_another_var,"toolcalc","height=400,width=640,noscroll,resizable");
            newwin = window.open("ais_transaction_jolist.php?FormName=[var.HTMLFormName]&SendToBack=1", "toolcalc","height=400,width=640,noscroll,resizable");
 }

 function OpenRemark (number) {
        newwin = window.open("ais_transaction_dn.php?PageMode=Remark&FormName=[var.HTMLFormName]&Number="+number,"remarks","height=105,width=300,noscroll,noresizable");
 }

 function OpenPrint (number) {
        newwin = window.open("ais_transaction_dn.php?PageMode=PrintPreview&nobkt="+number,"print","height=650,width=600,noscroll,noresizable");
 }


 function GetSkada() {
         skada1 = document.[var.HTMLFormName].thbl.value;
         if (skada1.length) LoadRPC ("iLoader", "[var.FileName]", "thbl="+document.[var.HTMLFormName].thbl.value);
 }


 function GetTotal () {
         document.[var.HTMLFormName].total_trans.value = SumTotal("jumlah");
 }


 /* added by dyah <dyah.mahrani@gmail.com>
 * 23 juli 2009
 * desc: COA filter based on group <payable/receivable>
 * */


 function getCashType(){
    var frm = document.[var.HTMLFormName].cash_type;
    return frm.options[frm.selectedIndex].value;
 }

var reccount = 1;
//if (reccount==0) reccount=1; else reccount=5;
var last;

function AddFormGridProject (cname,firstelemen) {
    var lastname ="";
    //alert("test");
    if (VerifyGridProject(reccount)==false) {
        return false
    }

    $(".gridBox:visible").each(function(n) {

        n = n+1;
        reccount = n;
        lastname = this.name;
        //alert(this.name);
    });

    lastname = lastname.substring(12);

    //alert("bufferku: " + bufferku);
    //alert("rec: " + reccount);
    //reccount = 5;
    //bufferku = parseInt(bufferku)+1;

    lastname = parseInt(lastname)+1;


    //alert("reccount: " + reccount);

    if (reccount>=100) {
        cname.disabled = true;
    }

    var objrow = document.getElementById("jobCosting" + lastname);
     //eval("var objrow = document.getElementById(jobCosting" + reccount + ")");
    //alert(reccount);
    if (objrow.style.display == 'none') {
        objrow.style.display = '';
    }

    eval(firstelemen+''+lastname+'.focus()');
    //alert(firstelemen+''+reccount);

    return false;
}



function AddFormGridCargo (cname,firstelemen) {
    if (VerifyGridCargo(reccount)==false) {
        return false
    }

    $(".gridBox2:visible").each(function(n) {
        n = n+1;
        reccount = n;
    });

    //reccount = 5;
    reccount = parseInt(reccount)+1;

    //alert("reccount: " + reccount);

    if (reccount>=100) {
        cname.disabled = true;
    }

    var objrow = document.getElementById(reccount);

    if (objrow.style.display == 'none') {
        objrow.style.display = '';
    }

    eval(firstelemen+''+reccount+'.focus()');

    return false;
}




function VerifyGridProject (x) {
    err_message = '';
    last_focus =0;
    if (err_message.length) {//alert(err_message);
    return false} else return true
}

function VerifyGridCargo (x) {
    err_message = '';
    last_focus =0;
    if (err_message.length) {//alert(err_message);
    return false} else return true
}

function CheckAllGrid(firstelemen) {
        for (n=1;n<reccount;n++) {
                if (!VerifyGrid(n)) return false;
        }
        eval('fl = document.'+firstelemen+reccount+'.value');
        if (fl.length)
                if (!VerifyGrid(reccount)) return false;
return true;}

 function GetReceived(val) {

     var getProjectValue = document.getElementById('projectname').value;

    //alert(getProjectValue);

     switch (val){
        case "1":
            newwin = window.open("ais_transaction_custlist_2.php?FormName=[var.HTMLFormName]&SendToBack=1&PageMode=Test&ProjectId=" + getProjectValue ,"toolcalc","height=400,width=640,noscroll,resizable");
            break;
     }
 }

 function maskMode(names,values){
    //alert(tes);
    oMask2 = new Mask('#,###.##', 'number');
    $("input[name="+names+"]").val(oMask2.format(values));

 }



 </script>


</html>
